/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package qgj.lib;

/**
 *
 * @author gluo
 */
public class Utils {
    
    /**
     * Verify Stock Code, must be like xxxxxx.sh or xxxxxx.sz.
     * @param code The stock code.
     * @return true if it's valid.
     */
    public static boolean verify_code(String code) {
        if (code==null) return false;
        else if (code.length()!=9) {
            return false;
        }
        else {
            String postfix = code.substring(6);
            String prefix = code.substring(0, 6);
            if ((postfix.equals(".sh") || postfix.equals(".sz"))) {
                try {
                    Integer.parseInt(prefix);
                }
                catch (NumberFormatException e) {
                    return false;
                }
                return true;
            }
            else
                return false;
        }
    }
    
    public static void p(Object s) {
        System.out.println(s);
    }
    
    public static void pf(String fmt, Object s) {
        System.out.printf(fmt, s);
    }
}
